package com.qf.framwork.filter;


import com.qf.framwork.utils.PropertiesUtils;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * description: 统一请求 响应编码的过滤器
 * author: Ken
 * 公众号：Java架构栈
 */
@WebFilter(urlPatterns = "/*")
public class Filter005Encoding implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
        request.setCharacterEncoding(PropertiesUtils.getProperties("req_encoding"));
        response.setCharacterEncoding(PropertiesUtils.getProperties("resp_encoding"));

        //放行
        filterChain.doFilter(request, response);
    }

    @Override
    public void destroy() {

    }
}
